package config

import (
	"github.com/go-redis/redis"
	"log"
)

var Redis *redis.Client

func init() {
	Redis = redis.NewClient(&redis.Options{
		Addr:        Addr,
		Password:    Password,
		DB:          DB,
		PoolSize:    PoolSize,
		MaxRetries:  MaxRetries,
		IdleTimeout: IdleTimeout,
	})
	_, err := Redis.Ping().Result()
	if err == redis.Nil {
		log.Panic("redis error:", err.Error())
	} else if err != nil {
		log.Panic("redis connect error:", err.Error())
	}
}
